package com.laobiao.file_netty_lib.packet.command;

import com.laobiao.file_netty_lib.exception.FileBaseException;

/**
 * 
 * @author 38079
 * 命令类型，支持[-127到128]中共256个命令
 */
public enum PacketCommandType {
	UPLOAD(0),//上传命令
	DOWNLOAD(1),//下载命令
	RESOULT(2),//通用反馈命令
	FILE_LIST(4),//目录文件列表查询命令
	DOWNLOAD_RESOULT(3),//异常
	FILE_DELETE(5),//文件删除
	MKDIR(6);//创建文件夹
	private int command;
	PacketCommandType(int command){
		this.command=command;
	}
	public int getCommand() {
		return command;
	}
	public void setCommand(int command) {
		this.command = command;
	}
	
	public static PacketCommandType instance(int command) {
		for(PacketCommandType commandType: PacketCommandType.values()) {
			if(commandType.getCommand()==command) {
				return commandType;
			}
		}
		throw new FileBaseException("数据错误，错误的命令:"+command, FileBaseException.ERR_PARAM_WRONG);
	}
}
